package com.demo;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.SmartInitializingSingleton;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSON;
import com.alibaba.nacos.api.config.annotation.NacosProperty;
@Component
public class DemoServer implements InitializingBean, SmartInitializingSingleton {

	
	@Autowired
	DemoConfig demoConfig;
	@Override
	public void afterPropertiesSet() throws Exception {
		System.out.println(JSON.toJSONString(demoConfig));
	}

	@Override
	public void afterSingletonsInstantiated() {
		System.out.println(JSON.toJSONString(demoConfig));
	}
	
	@KafkaListener(topics = "quickstart-events",groupId = "hello"+"#{T(java.util.UUID).randomUUID()}")
	public void kafkaconsumer(String message) {
		System.out.println(message);
	}
	
//	@Scheduled(fixedDelay = 2000)
//	public void run() {
//		System.out.println(JSON.toJSONString(demoConfig));
//	} 
}
